<?php
require_once("admin-header.php");
require_once("../lang/cn.php");
require_once ("../config/path_config.php");
require_once (ROOTDIR."config/sys_config.php");
?>

<html>
<head>
<title>后台管理</title>
</head>

<body>
<hr>
<h4>
<ol>
	<li>
		<a class='btn btn-primary' href="../status.php" target="_top"><b>查看前台</b></a>
    </li>

    <?php
    // 目前仅管理员可编辑和查看题目
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['problem_editor']);
    if ( $allowAccess ) {
    ?>
        <li>
            <a class='btn btn-primary' href="problem_clone.php" target="main"><b>题目克隆</b></a>
        </li>
        <li>
            <a class='btn btn-primary' href="problem_copy.php" target="main"><b>题目同步</b></a>
        </li>
        <li>
            <a class='btn btn-primary' href="view/problem_import.php" target="main"><b>题目导入</b></a>
        </li>
        <li>
            <a class='btn btn-primary' href="problem_add_page.php" target="main"><b>添加题目</b></a>
        </li>
        <li>
            <a class='btn btn-primary' href="problem_list.php" target="main"><b>题目列表</b></a>
        </li>
    <?php } ?>

    <?php
    // 教师和管理员可布置作业和查看题目完成情况
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['teacher']);
    if ( $allowAccess ) {
        ?>
        <!--
        暂未开发该功能
        <li>
            <a class='btn btn-primary' href="homework_list.php" target="main"><b>作业管理</b></a>
        </li>
        <li>
            <a class='btn btn-primary' href="answer_list.php" target="main"><b>答题统计</b></a>
        </li>
        -->
    <?php } ?>
    <!--用户列表与用户管理-->
    <?php
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['jgadmin']);
    $allowAccess |= isset($_SESSION['xxadmin']);

    $userMgrUrl = "";
    if ( isset($_SESSION['administrator']) || isset($_SESSION['jgadmin']) ) {
        $userMgrUrl = "view/user_mgr_company.php";
    }
    else {
        $userMgrUrl = "view/user_mgr_school.php";
    }
    if ( isset(SysConfig::$VEND_FOR) && SysConfig::$VEND_FOR != 'company' ) {
        $userMgrUrl = "view/user_mgr_".SysConfig::$VEND_FOR.".php";
    }
    if ( $allowAccess ){
        ?>
        <!--
        暂不开放该功能
        <li>
            <a class='btn btn-primary' href="user_list.php" target="main"><b>用户列表</b></a>
        </li>
        -->
        <li>
            <a class='btn btn-primary' href="<?php echo $userMgrUrl?>" target="main"><b>用户管理</b></a>
        </li>
    <?php } ?>
    <?php
    // 仅超管和机构管理员可修改密码，暂不开放给老师
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['jgadmin']);
    if ( $allowAccess ){
        ?>
        <li>
            <a class='btn btn-primary' href="changepass.php" target="main"><b>修改密码</b></a>
        </li>
    <?php } ?>

    <?php
    // 1. 超级管理员和老师,可删除指定题目的状态
    // 2. 教师只允许删除自己和自己所教学生的提交记录
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['teacher']);
    if ( $allowAccess ){
    ?>
	<li>
		<a class='btn btn-primary' href="status_list.php" target="main"><b>状态列表</b></a>
    </li>
    <?php }?>

    <?php
    // 仅管理员拥有权限创建比赛
    if (isset($_SESSION['administrator']) ) {
    ?>
        <!--
    <li>
        <a class='btn btn-primary' href="contest_add.php" target="main"><b>创建比赛</b></a>
    </li>
    <li>
        <a class='btn btn-primary' href="contest_list.php" target="main"><b>比赛列表</b></a>
    </li>
    -->
    <?php } ?>

    <?php
    // 1. 仅管理员可设置用户权限和查看权限列表
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['jgadmin']);
    if ( $allowAccess ) {
    ?>
    <li>
        <a class='btn btn-primary' href="privilege_add.php" target="main"><b>添加权限</b></a>
    </li>
    <li>
        <a class='btn btn-primary' href="privilege_list.php" target="main"><b>权限列表</b></a>
    </li>
    <?php } ?>

    <?php
    if ( isset($_SESSION['administrator']) ) {
    ?>
    <!--
    <li>
	    <a class='btn btn-primary' href="team_generate.php" target="main"><b><?php echo $MSG_TEAMGENERATOR?></b></a>
    </li>
        -->
    <li>
	    <a class='btn btn-primary' href="rejudge.php" target="main"><b><?php echo $MSG_REJUDGE?></b></a>
    </li>
    <?php } ?>
    <?php
    $allowAccess = isset($_SESSION['administrator']);
    $allowAccess |= isset($_SESSION['jgadmin']);
    if ( $allowAccess ) {
    ?>
    <p></p>
    <li>
        <a class='btn btn-primary' href="view/course_schedule_list.php" target="main"><b>排课&教学</b></a>
    </li>
    <li>
        <a class='btn btn-primary' href="view/summary_eval_list.php" target="main"><b>学员评价</b></a>
    </li>
    <li>
        <a class='btn btn-primary' href="setmsg.php" target="main"><b><?php echo $MSG_SETMESSAGE?></b></a>
    </li>
    <li>
        <a class='btn btn-primary' href="../online.php" target="main"><b><?php echo $MSG_ONLINE?></b></a>
    </li>
    <?php } ?>

    <?php
    if (isset($_SESSION['administrator'])){
    ?>
    <!--
    <li>
	    <a class='btn btn-primary' href="https://github.com/zhblue/freeproblemset/" target="_blank"><b>FreeProblemSet</b></a>
    </li>
    <li>
	    <a class='btn btn-primary' href="http://tk.hustoj.com" target="_blank"><b>TK题库</b></a>
    </li>
    -->
    <?php } ?>
</ol>
</h4>
</body>
</html>
